Home:ALL Converter>How to pass extra data to Swashbuckle custom JavaScript

How to pass extra data to Swashbuckle custom JavaScript

Ask Time:2019-01-27T16:05:08         Author:peterc

Json Formatter

I have an asp.net WebApi REST application where I have included Swashbuckle to get Swagger support for my endpoints.

I have injected some custom JavaScript where I want to customize the header section of the UI (a bit more than what I can so with just the CSS).

Ie I have added.

.EnableSwaggerUi( c =>
   c.InjectJavaScript(Assembly.GetExecutingAssembly(), "my.swagger.js");

I wish to pass some extra data to this JavaScript so I can the add to the custom header I will build in code.

Adding a breakpoint in my JavaScript, I can see the following objects in the global scope...

- swaggerApi
- swaggerUi
- swashbuckleConfig

Is there any way add some data to any of these objects (from my C# code), so I can then consume it in my JavaScript?

Author:peterc,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/54386203/how-to-pass-extra-data-to-swashbuckle-custom-javascript
yy